package com.my.yyr.security;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

public class CurrUser implements UserDetails {


    private String username;//用户账号
    private String factname;//用户姓名
    private String password;
    private boolean enabled;

    private Collection<? extends GrantedAuthority> authorities;//用户拥有的权限

    public CurrUser(String username, String factname, String password, boolean enabled, Collection<? extends GrantedAuthority> authorities) {
        this.username = username;
        this.factname = factname;
        this.password = password;
        this.enabled = enabled;
        this.authorities = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {//账号
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }

    public String getFactname() {
        return factname;
    }
}
